package sort;

/**
 * 优化的冒泡排序
 * BubbleSortOptimization
 */
public class BubbleSortOptimization implements Sort{

	@Override
	public void sort(int[] array) {

        if(array.length == 0){
            return;
        }
        for (int i = 0; i < array.length - 1; i++) {
            for (int j = 1; j < array.length; j++) {
                int tmp =0;
                if(array[j] < array[j - 1]){
                    tmp = array[j - 1];
                    array[j-1] = array[j];
                    array[j] = tmp;
                    break;
                }
            }
        }
    }

}